home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / xobbs.arc / xoio.c < prev    next >
C/C++ Source or Header  |  1989-05-03  |  2KB  |  85 lines

  1. /*XOIO.C  Input/Output routines for XOBBS. Jim Durham, W2XO 2-13-89 */
  2. /*Version 1.1*/
  3. /*Code released to the amateur radio community*/
  4.  
  5. #include "xobbs.h"
  6.  
  7. getline(mode)
  8.     int mode;
  9. {
  10.     static int msgbytes,savcnt,i;
  11.     static char *mp,*cp;
  12.     static char savbuf[1024];               /* buffer for saved chars */
  13.     
  14.     if(local){                               /* if local, get input from stdin*/
  15.         fgetline(infd,inline);
  16.         alarm(180);
  17.     }
  18.     else{
  19.         if(savcnt){
  20.             strncpy(msg.mtext,savbuf,savcnt);
  21.             msgbytes = savcnt;
  22.         }
  23.         else{
  24.             msgbytes = msgrcv(rmsgqid,&msg,1024,(long)pid,0600);/*get a message*/
  25.         }
  26.         cp = inline;
  27.         mp = msg.mtext;                 /*point to message text*/
  28.         while(((*cp = *mp) != 0x0d) && ((*cp != 0x0a)
  29.           && ((int)(cp-inline) < 254))){
  30.            cp++;
  31.            mp++;
  32.            msgbytes--;
  33.            if(msgbytes < 1){
  34.                msgbytes = msgrcv(rmsgqid,&msg,1024,(long)pid,0600);
  35.                mp = msg.mtext;
  36.            }
  37.         }
  38.     if((*cp != 0x0d) && (*cp != 0x0a))
  39.         cp++;
  40.         *cp = '\0';
  41.         msgbytes--;                 /*count the CR*/
  42.         mp++;                       /* and skip it*/
  43.         savcnt = msgbytes;
  44.         strncpy(savbuf,mp,msgbytes);
  45.     }
  46.     if(mode == 1) return;
  47.  
  48.     i = strlen(inline);
  49.     while(i--) if(islower(inline[i])) inline[i]=toupper(inline[i]);
  50.  
  51. }
  52.         
  53. cgetline()
  54. {
  55.     int gotbytes;
  56.  
  57.  
  58.  
  59.  
  60.     if(local)
  61.         printf("cgetline called from local!\n");
  62.     else{    /*get a message from the receive que*/
  63.         if((gotbytes = msgrcv(rcmsgqid,&msg,1024,(long)pid,0600)) < 0){
  64.                 perror("cgetline");
  65.                 gotbytes = 0;
  66.         }
  67.         msg.mtext[gotbytes] = '\0';
  68.     strcpy(inline,msg.mtext);
  69.     } /*if local/else */
  70. }
  71.  
  72.  
  73. printerr()
  74. {
  75.     sprintf(prinbuf,"\n*** Bad Command\n");
  76.     prinout(NOFLUSH);
  77. }
  78.              
  79. printnone()
  80. {
  81.     sprintf(prinbuf,"\n*** None Found\n");
  82.     prinout(NOFLUSH);
  83. }
  84.  
  85.